package com.sw.haruka.module.title

import android.content.Context
import android.content.Intent
import android.view.View
import android.widget.PopupMenu
import com.sw.haruka.R
import com.sw.haruka.helper.utils.ActivityUtils
import com.sw.haruka.module.about.AboutFragment
import com.sw.haruka.module.ftp.FTPFragment
import com.sw.haruka.view.SettingActivity

class MorePopupMenu(context: Context?, anchor: View?) :
    PopupMenu(context, anchor) {
    init {
        menuInflater.inflate(R.menu.main_more, menu)
        setOnMenuItemClickListener { item ->
            when (item.itemId) {
                R.id.action_about -> ActivityUtils.mainActivity?.get()?.showLayer2(AboutFragment())
                R.id.action_setting -> ActivityUtils.mainActivity?.get()?.startActivity(Intent(context, SettingActivity::class.java))
                R.id.action_ftp -> {
                    ActivityUtils.mainActivity?.get()?.showLayer2(FTPFragment())
                }
                else -> {}
            }
            false
        }
    }
}